import Vue from 'vue'
import VueRouter from 'vue-router'


const routes = [
  {
    path: '/',
    name: 'index',
    component: () => import('../view/index.vue')
  },
  {
    path: '/list',
    name: 'list',
    component: () => import('../view/list.vue')
  },
  {
    path: '/detail',
    name: 'detail',
    component: () => import('../view/detail.vue')
  },
]
//去除重复点击当前路由 报错的问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
const original = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return original.call(this, location).catch(err => err)
};
export default router
